<
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
/
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
h
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
t
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
m
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
l
In [58]:
import matplotlib.pyplot as plt
plt.plot([1,2,3,6]) #生成的是y的数据,所以x会自动生成。
plt.ylabel('some numbers')
plt.show()
In [63]:
plt.plot([1,2,3,4,5,6,7,8],[1,4,9,16,25,36,49,64])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f7e8bffee80>]
In [66]:
plt.plot([1,2,3,4],[1,4,9,16],'ro')
plt.axis([0,6,0,20])
plt.show()
In [70]:
import numpy as np
t = np.arange(0.,5.,0.2)
print(t)
plt.plot(t,t,'r--',t,t**2,'bs',t,t**3,'g^')
plt.show()
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.4
 3.6 3.8 4.  4.2 4.4 4.6 4.8]
In [72]:
data = {'a':np.arange(50),
       'c':np.random.randint(0,50,50),
       'd':np.random.randn(50)}
data['b'] = data['a'] + 10*np.random.randn(50)
data['d'] = np.abs(data['d'])*100

plt.scatter('a','b',c = 'c',s='d',data = data)
plt.xlabel('entry a')
plt.ylabel('entry b')
plt.show()
In [75]:
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(1, figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
In [88]:
#使用多轴承画图
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0,5.0,0.1)
t2 = np.arange(0.0,5.0,0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2),'k')

plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2),'r--')
plt.show()
In [115]:
import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot(211)
plt.plot([1,2,3])

plt.subplot(212)
plt.plot([4,5,6])

plt.figure(2)
plt.plot([4,5,6])

plt.figure(1)
plt.subplot(212)
plt.plot([4,6,2,1])
plt.title("easy as 1,2,3")
Out[115]:
Text(0.5, 1.0, 'easy as 1,2,3')
In [132]:
mu,sigma = 100,15
x = mu + sigma*np.random.randn(10000)
n,bins,patches = plt.hist(x,50,density=1,facecolor='g',alpha=0.75)

plt.xlabel('Smart')
plt.ylabel('probability')

plt.title('Histogram of IQ')
plt.text(50,.025,r'a=1,\ $\mu = 100,\ \sigma = 15$')
plt.axis([40, 160, 0, 0.03])
#plt.grid(True)
plt.show()
In [150]:
ax = plt.subplot(111)

t = np.arange(0.0,5.0,0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t,s,lw=2)
plt.annotate('local max',xy = (2,1),xytext=(3,1.5),
            arrowprops=dict(facecolor='black',shrink=5))
plt.ylim(-2,2)
#plt.xlim(-5,5)
plt.xscale('log')
plt.show()
In [153]:
from matplotlib.ticker import NullFormatter
#fix random state for reproducibility
np.random.seed(19680801)

#make up some data in the interval ]0,1[
y = np.random.normal(loc=0.5,scale=0.4,size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

#plot with various axes acales
plt.figure(1)

#linear 
plt.subplot(221)
plt.plot(x,y)
plt.yscale('linear')
plt.title('linear')
plt.grid(True)

#log
plt.subplot(222)
plt.plot(x,y)
plt.yscale('log')
plt.title('log')
plt.grid(True)

#symmetric log
plt.subplot(223)
plt.plot(x, y - y.mean())
plt.yscale('symlog', linthreshy=0.01)
plt.title('symlog')
plt.grid(True)

#logit
plt.subplot(224)
plt.plot(x,y)
plt.yscale('logit')
plt.title('logit')
plt.title('logit')
plt.grid(True)

plt.gca().yaxis.set_minor_formatter(NullFormatter())
plt.subplots_adjust(top = 0.92,bottom=0.08,left=0.10,right=0.95,hspace=0.25,
                   wspace=0.35)
plt.show()
In [11]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
plt.figure(figsize=(14, 10))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'k',marker='<',label='train acc')
plt.plot(data[:,3],'b--',markersize=1,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename1.png")
plt.figure(2)
plt.figure(figsize=(14, 10))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = {'size':11})
plt.savefig("/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/filename2.png")
plt.show()
<Figure size 432x288 with 0 Axes>
In [ ]:
 
In [97]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
data = np.loadtxt('/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/14/VGG16__loss_epoch.txt',delimiter=',')
plt.figure(1)
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b',label='train acc')
plt.plot(data[:,3],'k',marker='<',markersize=3,label='val acc')
plt.xlabel('epoch')
plt.ylabel('acc')
plt.title('InceptionResNetV2 train accuracy and validation accuracy')
plt.legend()
plt.figure(2)
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=4,label='val loss')
plt.xlabel('epoch')
plt.ylabel('loss')
plt.title('InceptionResNetV2 train loss and validation loss')
plt.legend()
plt.show()
In [8]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
for i in range(20000,20013):
    rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/deal-data-whole5/VGG19/'
    datapath = rootpath + str(i)+'/VGG19__lose_epoch.txt'
    data = np.loadtxt(datapath,delimiter=',')
    plt.figure(1)
    plt.figure(figsize=(12, 8))
    #plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
    plt.plot(data[:,1],'k',marker='<',label='train acc')
    plt.plot(data[:,3],'b--',markersize=1,label='val acc')
    plt.xlabel('epoch',font2)
    plt.ylabel('acc',font2)
    #plt.title('Vgg16 train accuracy and validation accuracy')
    plt.legend(loc = 0, prop=font1)
    plt.savefig(rootpath+str(i)+"/filename1.png")
    plt.figure(2)
    plt.figure(figsize=(12, 8))
    plt.plot(data[:,0],'r--',label='train loss')
    plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
    plt.xlabel('epoch',font2)
    plt.ylabel('loss',font2)
    #plt.title('Vgg16 train loss and validation loss')
    plt.legend(loc = 0, prop = font1)
    plt.savefig(rootpath+str(i)+"/filename2.png")
    plt.show()
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [5]:
import matplotlib.pyplot as plt
import matplotlib.collections as mcol
from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple
from matplotlib.lines import Line2D
import numpy as np
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 13,
}

rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
datapath = rootpath + '/DenseNet201__loss_epoch.txt'
data = np.loadtxt(datapath,delimiter=',')
plt.figure(1)
plt.figure(figsize=(12, 8))
#plt.plot(data[:,0],'r--',data[:,1],'g^',data[:,2],'bs',data[:,3],'bo')
plt.plot(data[:,1],'b--',markersize=1,label='train acc')
plt.plot(data[:,3],'k',marker='<',label='val acc')
plt.xlabel('epoch',font2)
plt.ylabel('acc',font2)
#plt.title('Vgg16 train accuracy and validation accuracy')
plt.legend(loc = 0, prop=font1)
plt.savefig(rootpath+"/filename1.png")
plt.figure(2)
plt.figure(figsize=(12, 8))
plt.plot(data[:,0],'r--',label='train loss')
plt.plot(data[:,2],marker='>',markersize=5,label='val loss')
plt.xlabel('epoch',font2)
plt.ylabel('loss',font2)
#plt.title('Vgg16 train loss and validation loss')
plt.legend(loc = 0, prop = font1)
plt.savefig(rootpath+"/filename2.png")
plt.show()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-e794c5c61526> in <module>
     15 rootpath = '/home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12'
     16 datapath = rootpath + '/DenseNet201__loss_epoch.txt'
---> 17 data = np.loadtxt(datapath,delimiter=',')
     18 plt.figure(1)
     19 plt.figure(figsize=(12, 8))

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
    953             fname = os_fspath(fname)
    954         if _is_string_like(fname):
--> 955             fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
    956             fencoding = getattr(fh, 'encoding', 'latin1')
    957             fh = iter(fh)

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(path, mode, destpath, encoding, newline)
    264 
    265     ds = DataSource(destpath)
--> 266     return ds.open(path, mode, encoding=encoding, newline=newline)
    267 
    268 

~/appStore/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py in open(self, path, mode, encoding, newline)
    622                                       encoding=encoding, newline=newline)
    623         else:
--> 624             raise IOError("%s not found." % path)
    625 
    626 

OSError: /home/nathan/workspace/liu刘新峰老师索要文档/数据分析资料/12/DenseNet201__loss_epoch.txt not found.
In [ ]:
 
>